/**
* @filename main.c
* @author Martin
* @brief Task schedule module source file
* @date 2019-07-09
* @version 0.1
* @note initial draft
*/

#include <Led.h>
#include "Task.h"
#include "S32K144.h"
#include "Port.h"
#include "Can.h"
#include "Tja1043.h"


// timer unit 1ms
#define TIMEROUT_1s           (1000)
#define TIMEROUT_10ms         (10)
#define TIMEROUT_ms(x)		  (x)
#define LED_TIMEROUT          TIMEROUT_1s


uint32_t timer_1s = 0;
uint32_t timer_10ms = 0;
uint32_t timer_100ms = 0;

void Task_Led(void)
{
	Port_Toggle(PTD, PORT_LED_GREEN_IDX);
}

void Task_MainCycle(void)
{

	while(1)
	{
		if(timer_10ms >= TIMEROUT_10ms)
		{
			timer_10ms = 0;

//			BCan_10ms();

//			Speed_10ms();

			Button_10ms();
		}

		if(timer_100ms >= TIMEROUT_ms(100))
		{
			timer_100ms = 0;

			FactoryTest_100ms();

//			Tja1043_100ms();
		}

//		if(timer_1s >= TIMEROUT_1s)
//		{
//			timer_1s = 0;
//
//			LED_Task_1s();
//		}
	}
}
